package com.example.weather_plus.ui.weatherforecast.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.weather_plus.R;
import com.example.weather_plus.data.model.HourlyWeatherForecast;

import java.util.List;

public class PreferCityWeatherAdapter extends RecyclerView.Adapter<PreferCityWeatherAdapter.CityWeatherViewHolder> {

    private List<HourlyWeatherForecast> cityWeatherList;
    private Context context;

    public PreferCityWeatherAdapter(Context context, List<HourlyWeatherForecast> cityWeatherList) {
        this.context = context;
        this.cityWeatherList = cityWeatherList;
    }

    @NonNull
    @Override
    public CityWeatherViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.hourly_weather_item, parent, false);
        return new CityWeatherViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(@NonNull CityWeatherViewHolder holder, int position) {
        HourlyWeatherForecast currentCityWeather = cityWeatherList.get(position);
//        holder.cityName.setText(currentCityWeather.getCityName());
        // 设置其他天气数据显示，如图标、温度等
    }

    @Override
    public int getItemCount() {
        return cityWeatherList.size();
    }

    public static class CityWeatherViewHolder extends RecyclerView.ViewHolder {
        TextView time;
        ImageView icon;
        TextView temp;
        // 其他视图组件，如天气图标、温度等

        public CityWeatherViewHolder(View itemView) {
            super(itemView);
            icon = itemView.findViewById(R.id.ivWeatherIcon);
            temp = itemView.findViewById(R.id.tvTemperature);

            // 初始化其他视图组件
            // TODO
        }
    }
}